Putting it in Perspective
One of my favorite features of wmii is tags1. These allow you to divide up windows into categories based on whatever you want.
The basic idea is really simple. Each window has a set of strings associated with it, called its “tags.” At any given moment, you are “viewing” a single tag. This means that only windows with that tag are displayed.
What’s more, each tag has a certain configuration of windows. This means that I can have Firefox in the upper-left corner for my programming tag but taking up the whole screen for my web tag.
Tags model perspectives
In some sense, wmii’s tags behave similarly to tags for, say, blog posts. Post tags categorize posts. If you look at the Emacs tag for this blog, you’ll get all the posts I’ve written about Emacs. If you look at the “im” tag on my computer, you’ll get all the windows that related to instant messaging.
But the point of wmii’s tags isn’t categorization. It’s more like the point of multiple desktops in Gnome or KDE. Tags encapsulate the perspectives from which you interact with the computer.
Perspectives are views of larger interactions
What do I mean by “perspectives?” I’m sure it varies from person to person, depending on how they use their tags or desktops. But I think it’s safe to assume that there are general trends.
First, let’s look at an example. Here is the list of tags I’m currently using:
check: For things I periodically check up on, like email and feeds. I also keep a browser here so I can easily check out links.im: Where I keep my Pidgin and an Emacs instance running rcirc.music: An instance of Quod Libet.prog: Emacs, a terminal, and whatever else might be handy for hacking.web: Just a browser. Sometimes several, if they’re called for.
These tags are, I think, a good example of perspectives. Perspectives are a level of granularity between individual applications and tasks.
None of these tags encompasses enough applications
to allow me to only work in that tag for a given workflow.
When I’m programming, I still switch to im every time I send a message.
While chatting, I’ll switch to web to look up a link.
At the same time, each tag contains enough functionality
to allow me to do what I want within that tag.
If I just want to check up on stuff,
check has both email and feeds.
prog has everything I need to just code.
Each tag offers a single perspective on my overall interaction with the computer.
I like this metaphor. It reflects that what happens when I switch tags, in the most literal sense, is a visual change. Some windows are hidden, some are made visible. Nothing actually changes; you just see a different aspect of what’s going on. A different perspective.
wmii’s tagging makes perspective stuff fast
The idea of perspective is independent of wmii-style tags. But tagging seems to be a good model for delineating perspectives, at least on the level of window management. In my experience, it works better than the traditional Linux multiple-desktop system, and it certainly beats the single-desktop model.
A large part of this is how quick it is to create a new tag. You can’t spontaneously add a new desktop, but you can trivially add a new tag. This means you don’t have to plan ahead which perspectives you’ll be using - you just create new ones as you go. When one perspective gets too dense, it can just spill over into a new one.
Tags also have the inherent property of being names. This gives explicit semantics to each perspective, making it easier to keep it to its purpose.
More importantly than semantics, naming perspectives also allows O(1) access. In the desktops model, the desktops are more or less a list: to reach the one you want, you flip through all the ones in between. But with tags, you just say “go to this tag.”
In ruby-wmii, this is narrowed down even further, so that switching tags is just one keystroke. Every M2-letter combination2 switches to the most-recently-accessed tag beginning with that letter.
This may seem trivial, but I think it’s important that wmii and ruby-wmii make such an effort to keep the keybindings for switching between tags as short as possible. I’d go so far as to say the main reason tags work so well is that the key bindings make working with them so quick.
So What?
Don’t worry, this post isn’t just ramblings about user interface. I actually have something useful to share as well.
See, tags are great for modeling perspectives in terms of application windows. But I spend easily half my time at the computer hacking on something in Emacs. Often I’m hacking on two or three different things simultaneously.
For example, suppose I’m hacking on ruby-wmii. Then a Haml bug report comes in, so I decide to fix that and add a few new features while I’m at it. In the middle of one of those, I discover a snazzy new bit of configuration, so I open up my config file.
At this point, I’ve got all sorts of buffers floating around.
All my window configuration and buffer-list ordering and so forth
for ruby-wmii has long since been lost.
If only I had some model for looking at different aspects of a larger system!
After going through this a few times, I decided I’d had enough, and wrote up a solution.
I give you perspective.el.
Not-quite-tagged perspective management for Emacs
Perspective.el allows you to define named perspectives,
each with their own set of buffers,
and switch between them.
All window configuration and buffer-list order is preserved.
Buffers don’t have tags. You wouldn’t want to have to manually tag every buffer. Instead, any buffer accessed when in a given perspective is automatically added to that perspective. This seems to map quite well to Emacs’ pick-buffers-as-you-go scheme.
At the moment, the keymap is not quite as easy-to-type as I would like.
Everything is under C-x x,
which seemed to be the easiest prefix
that wasn’t already taken up.
I’m thinking of binding C-S-letter, ruby-wmii-style,
to switch to the first perspective
whose name starts with the given letter.
The following basic functions are available:
persp-switch(C-x x s): Switch to a different perspective, or create a new one.persp-rename(C-x x r): Rename the current perspective.persp-remove-buffer(C-x x k): Remove a buffer from the current perspective, killing it if it no longer belongs to any perspective.persp-kill(C-x x c): Kill the current perspective, as well as any buffers belonging only to this perspective.
Get it and install it
The best way to get perspective.el is to clone it via Git. To do so, run
git clone git://github.com/nex3/perspective-el.git
You can also just download the file from the web repo. Either way, once you have the actual file, copy it to your load path and add
(require 'perspective)
to your .emacs. You should be good to go.
Update: I changed a few of the keybindings and added persp-rename.
Update 2: You can now activate the C-S-letter bindings using (quick-perspective-keys).
1 Others include wmii’s basic tiling-window-manager-ness and Mauricio Fernandez’s excellent Ruby extension setup.
2 I’m using a hybrid of Emacs and wmii key terminology here. Wmii uses two modifier keys, but what they are can be customized by the user. Thus, I refer to the first one as M1 and the second as M2.
About Me
Feed
Distributed Version Control



Awesome! I’m using it right now and it seems to work very nicely. So when are you going to rewrite wmii in elisp?
The thing that turned me away from WMII is that you lose out on all the hard work that people are doing on things like Gnome and KDE. You lose out on wireless applets, and system updaters, and configuration management, not to mention now you lose things like Compiz or whatever they are calling it these days.
You can use most, if not all, of the Gnome/KDE apps. Even the panels are reasonably workable, if you can reconcile them with being treated like any other window.
You do have to sacrifice Compiz. That comes down to the choice between eye candy and personal efficiency. Once I got into wmii, I was a little surprised to find myself not missing Compiz at all.
I’m not sure if you are aware of this, but perspective.el doesn’t seem to play well with ERC
How do you mean, valnour? I’ve actually stopped using ERC in favor of rcirc, so I haven’t noticed that.
valnour: why re-write wmii in elisp, would it differ significantly enough from stumpwm?